package com.wholesale.utils;

import android.content.Context;
import android.text.ClipboardManager;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

import com.wholesale.R;

public class TrackingPackagesCache implements OnClickListener {
	private View baseView;
	private TextView orderNumber;
	private TextView shippingNumber;
	private TextView orderTime;
	private TextView paymentTime;
	private TextView shippingTime;
	private TextView shippingTape;
	private TextView shippingStatus;
	private Button copyButton;

	public TrackingPackagesCache(View baseView) {
		this.baseView = baseView;
	}

	public TextView getOrderNumber() {
		if (orderNumber == null) {
			orderNumber = (TextView) baseView
					.findViewById(R.id.ordernumber_text);
		}
		return orderNumber;
	}

	public TextView getShippingNumber() {
		if (shippingNumber == null) {
			shippingNumber = (TextView) baseView
					.findViewById(R.id.shipping_text);
		}
		return shippingNumber;
	}

	public TextView getOrderTime() {
		if (orderTime == null) {
			orderTime = (TextView) baseView.findViewById(R.id.ordertime_text);
		}
		return orderTime;
	}

	public TextView getPaymentTime() {
		if (paymentTime == null) {
			paymentTime = (TextView) baseView
					.findViewById(R.id.paymentTime_text);
		}
		return paymentTime;
	}

	public TextView getShippingTime() {
		if (shippingTime == null) {
			shippingTime = (TextView) baseView
					.findViewById(R.id.shippingTime_text);
		}
		return shippingTime;
	}

	public TextView getShippingTape() {
		if (shippingTape == null) {
			shippingTape = (TextView) baseView
					.findViewById(R.id.shippingtape_text);
		}
		return shippingTape;
	}

	public TextView getShippingStatus() {
		if (shippingStatus == null) {
			shippingStatus = (TextView) baseView
					.findViewById(R.id.shippingstatus_text);
		}
		return shippingStatus;
	}

	public Button getCopyButton() {
		if (copyButton == null) {
			copyButton = (Button) baseView.findViewById(R.id.btnCopyShippingID);
			copyButton.setOnClickListener(this);
		}
		return copyButton;
	}

	@Override
	public void onClick(View v) {
		ClipboardManager clipboard = (ClipboardManager) Constants.appContext
				.getSystemService(Context.CLIPBOARD_SERVICE);
		clipboard.setText(getShippingNumber().getText());
	}

}
